package com.xx.controller;

import com.github.pagehelper.PageInfo;
import com.xx.common.R;
import com.xx.entity.Student;
import com.xx.pojo.po.StudentQueryPo;
import com.xx.service.StudentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/student")
@Api(tags = "学生接口")
public class StudentController {

    @Autowired
    private StudentService studentService;

    @GetMapping(path = "/list")
    @ApiOperation("获取学生列表")
    public R list() {
        return R.ok(studentService.list());
    }

    @GetMapping(path = "/page")
    @ApiOperation("学生列表分页")
    public R page(@Validated StudentQueryPo po) {
        PageInfo<Student> page = studentService.queryPage(po);
        return R.ok(page);
    }
}
